fix: handle Schlage masked usercode responses with varying PIN lengths#559
fix: handle Schlage masked usercode responses with varying PIN lengths#559raman325 wants to merge 4 commits intoFutureTense:betafrom
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes handling of Schlage lock masked usercode responses for PINs with varying lengths (not just 4 digits). The main issue was that the code used isdigit() checks which failed to detect masked responses that consisted of repeated characters of any length.
Changes:
- Improved masked usercode detection using
len(set(usercode)) == 1to identify any single-character repeated pattern - Enhanced verification logic for cleared usercodes to handle varying PIN lengths
- Style improvements: converted lists to tuples in for loops (pylint R6102 compliance)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| custom_components/keymaster/coordinator.py | Enhanced masked usercode detection logic to use set-based checking for any single-character pattern; added loop to check multiple mask characters with early exit |
| custom_components/keymaster/providers/zwave_js.py | Refactored cleared usercode verification to use dynamic length checking; moved debug log to else block for better flow; added return False for verification failures |
| custom_components/keymaster/migrate.py | Style fix: converted list to tuple in for loop |
| custom_components/keymaster/init.py | Style fix: converted list to tuple in for loop |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## beta #559 +/- ##
==========================================
+ Coverage 80.86% 84.58% +3.72%
==========================================
Files 19 25 +6
Lines 2341 2731 +390
==========================================
+ Hits 1893 2310 +417
+ Misses 448 421 -27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
This PR fixes an issue with Schlage locks that have PINs with lengths other than 4 digits. The masked usercode response uses repeated characters (e.g., "**********" or "0000000000") which need to be detected regardless of length.
Breaking change
None.
Proposed change
Coordinator changes (
coordinator.py)len(set(usercode)) == 1to detect any single-character repeated pattern for masked responsesbreakafter clearing usercode to exit loop earlyZ-Wave JS Provider changes (
zwave_js.py)elseblock after successful clear operationFalsewhen verification fails to properly trigger retry logicStyle fixes
forloops (pylint R6102) in:__init__.pycoordinator.pymigrate.pyType of change
Additional information
🤖 Generated with Claude Code